<?php /*a:2:{s:68:"/www/wwwroot/cloud_boss/application/admin/view/equipment/libary.html";i:1604050254;s:64:"/www/wwwroot/cloud_boss/application/admin/view/public/basic.html";i:1573743224;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo htmlentities((isset($title) && ($title !== '')?$title:'重庆优合一众')); ?></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/static/plugs/layui/css/layui.css" media="all"/>
    <!--<link rel="stylesheet" href="/static/layuicms/css/index.css" media="all" />-->
    
<link rel="stylesheet" href="/static/css/admin/public.css" media="all"/>

</head>
<body class="<?php echo htmlentities((isset($body) && ($body !== '')?$body:'childrenBody')); ?>">

<form class="layui-form">
    <blockquote class="layui-elem-quote quoteBox">
        <form class="layui-form">
            <div class="layui-inline">
                <input type="hidden" id="app_sn" value="<?php echo htmlentities($app_sn); ?>">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input device_no" placeholder="请输入主板号"/>
                </div>
<!--                <div class="layui-input-inline">-->
<!--                    <select name="sim_status" class="sim_status" lay-filter="status">-->
<!--                        <option value="">请选择状态</option>-->
<!--                        <option value="-1">未知状态</option>-->
<!--                        <option value="0">待激活</option>-->
<!--                        <option value="1">已激活</option>-->
<!--                        <option value="2">已停机</option>-->
<!--                        <option value="3">已拆机</option>-->
<!--                    </select>-->
<!--                </div>-->
                <a class="layui-btn search_btn" data-type="reload">搜索</a>
            </div>


            <div class="layui-inline">
                <a class="layui-btn layui-btn-sm addNews_btn" onclick="update()">更新SIM信息</a>
            </div>

            <?php if(auth("$thisClass/add")): ?>
            <div class="layui-inline">
                <a class="layui-btn layui-btn-warm layui-btn-sm addNews_btn">添加设备</a>
            </div>
            <?php endif; ?>
            <div class="layui-inline">
                <a class="layui-btn layui-btn-sm layui-bg-cyan" onclick="downloadDevice()">下载设备导入模板</a>
            </div>
            <?php if(auth("$thisClass/import")): ?>
            <div class="layui-form-item layui-inline">
                <a class="layui-btn layui-btn-sm import_btn layui-bg-cyan">导入</a>
            </div>
            <?php endif; ?>

        </form>
    </blockquote>
    <table id="userList" lay-filter="userList"></table>


</form>

<script type="text/javascript" src="/static/plugs/jquery/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="/static/plugs/layui/layui.js"></script>
<script type="text/javascript" src="/static/admin.js"></script>
<script type="text/javascript" src="/static/js/admin/api.js"></script>

<script>
    layui.use(['laydate', 'form', 'layer', 'table', 'laytpl'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laytpl = layui.laytpl,
            table = layui.table,
            laydate = layui.laydate;

        //日期范围
        laydate.render({
            elem: '#create_at'
            , range: true
        });
        var api_host = "<?php echo htmlentities($api_host); ?>";
        //用户列表
        var tableIns = table.render({
            elem: '#userList',
            url: api_host + 'Boss/Equipment/libaray',
            method: 'POST',
            contentType: 'application/json; charset=UTF-8',
            headers: {
                "token": 'bbbbb'
            },
            where:{app_sn:$("#app_sn").val()},
            cellMinWidth: 95,
            page: true,
            height: "full-125",
            limits: [10, 15, 20, 25],
            limit: 20,
            id: "userListTable",
            request: {
                limitName: 'pageSize', //每页数据量的参数名，默认：limit
            },
            cols: [[
                {field: 'device_no', title: '设备号', minWidth: 200, align: "center"},
                {field: 'sim_sn', title: 'iccid', minWidth: 200, align: 'center'},
                // {field: 'sim_status_desc', title: '状态', align: 'center'},
                {field: 'activa_time', title: '激活时间', minWidth: 200, align: 'center'},
                {field: 'expire_time', title: '到期时间', minWidth: 200, align: 'center'},
                {field: 'add_time', title: '入库时间', minWidth: 200, align: 'center'},
                {field: 'seet_meal', title: '套餐', align: 'center'},
            ]]
        });

        //搜索【此功能需要后台配合，所以暂时没有动态效果演示】
        $(".search_btn").on("click", function () {

            if ($(".searchVal").val() != '') {
                //执行重载
                table.reload('userListTable', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        //传参数
                        device_no: $(".device_no").val(),
                        sim_status: $(".sim_status").val(),
                        app_sn: $("#app_sn").val(),
                    },

                });
                table.render();
                // layer.msg('查询成功');
            } else {
                layer.msg("请输入搜索的内容");
            }
        });

    });

    $(".addNews_btn").click(function () {
        addUser();
    });


    // 添加设备库
    function addUser(edit) {
        var index = layui.layer.open({
            title: "新增设备库",
            type: 2,
            content: '<?php echo url("$thisClass/add"); ?>?app_sn='+$("#app_sn").val(),
            success: function (layero, index) {

                setTimeout(function () {
                    layui.layer.tips('点击此处返回列表', '.layui-layer-setwin .layui-layer-close', {
                        tips: 3
                    });
                }, 500)
            }
        });
        layui.layer.full(index);
        //改变窗口大小时，重置弹窗的宽高，防止超出可视区域（如F12调出debug的操作）
        $(window).on("resize", function () {
            layui.layer.full(index);
        })
    }


    function update() {
        layer.msg('正在查询...查询时间较长,请耐心等待~~~~', {
            icon: 1,
            time: 60000 //2秒关闭（如果不配置，默认是3秒）
        }, function(){
            //do something
        });
        var api_host = "<?php echo htmlentities($api_host); ?>";
        $.post(api_host + 'Common/Sim/getIms', {}, function (data) {
            layer.closeAll();
            //console.log(data,"dd");
           layer.msg(data.msg);

        })

    }

    // 下载主板导入模板
    function downloadDevice(){
        window.location.href = "<?php echo config('api.qi_niu_url'); ?>" + 'excel_template.xlsx';
    }

    //导入
    $(".import_btn").click(function () {
        var index = layui.layer.open({
            title: "导入",
            type: 2,
            content: '<?php echo url("$thisClass/import"); ?>?app_sn='+$("#app_sn").val(),
            success: function (layero, index) {

                setTimeout(function () {
                    layui.layer.tips('点击此处返回列表', '.layui-layer-setwin .layui-layer-close', {
                        tips: 3
                    });
                }, 500)
            }
        });
        layui.layer.full(index);
        //改变窗口大小时，重置弹窗的宽高，防止超出可视区域（如F12调出debug的操作）
        $(window).on("resize", function () {
            layui.layer.full(index);
        })
    });

</script>

</body>
</html>